package com.mobi.cacti.rabbit.response;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;



import android.util.Log;

public class ReqMobileLoginHandler extends DefaultHandler {
	private String tempVal;
	private GraphCircuit dt;
	private ReqMobileLogin oClass;

	public ReqMobileLoginHandler() {
		
	}

	public ReqMobileLogin getObj() {
		return oClass;
	}

	public void startElement(String uri, String localName, String qName,Attributes attributes) throws SAXException {
		// reset
		
		Log.i("tai", "localName start>>> "+localName);
		
		tempVal = "";
		if (localName.equalsIgnoreCase("ReqMobileLogin")) {
			oClass = new ReqMobileLogin(); //create object class
		}else if (localName.equalsIgnoreCase("Resposne_nms")) {
			oClass.initLinked(); //create linked Resposne_nms	
		}else if (localName.equalsIgnoreCase("Circuit")) { //isExist attributes id
			dt = new GraphCircuit();	
			dt.CircuitID = attributes.getValue("id");
			oClass.initLinked();
			oClass.responseCircuitIDWhenLogin.put(dt.CircuitID, dt);
		}
		else if (localName.equalsIgnoreCase("Graph_Total_id")){
			dt.Graph_Total_ID = attributes.getValue("id");
		}else if (localName.equalsIgnoreCase("Graph_Inter_id")){	
			dt.Graph_Inter_ID = attributes.getValue("id");
		}else if (localName.equalsIgnoreCase("Graph_Domestic_id")){	
			dt.Graph_Domestic_ID = attributes.getValue("id");
		}
	}

	public void characters(char[] ch, int start, int length) throws SAXException {
		tempVal = new String(ch, start, length);
//		Log.i("tai", ">>> "+tempVal);
	}

	public void endElement(String uri, String localName, String qName) throws SAXException 
	{
		Log.i("tai", "qName end>>> "+qName);
		
		if (qName.equalsIgnoreCase("ReqSessionID")){
			oClass.ReqSessionID = tempVal;
		}else if (qName.equalsIgnoreCase("ResSessionID")){	
			oClass.ResSessionID = tempVal;
		}else if (qName.equalsIgnoreCase("Code_Response")){	
			oClass.Code_Response = tempVal;
		}else if (qName.equalsIgnoreCase("ContactNo")){
			oClass.ContactNumber = tempVal;
		}else if (qName.equalsIgnoreCase("ContactEmail")){
			oClass.ContactEmail = tempVal;
		}
	}

}
